﻿// -----------------------------------------------------------------------
// <copyright file="DateTimePluralizer.cs" company="Moveax, LLC">
// Copyright (c) 2013 Andrey Veselov. All rights reserved.
// License:  Microsoft Public License (MS-PL)
// Contacts: http://andrey.moveax.com andrey@moveax.com
// </copyright>
// -----------------------------------------------------------------------

namespace Moveax.Pluralization.Common
{
    using System.Globalization;
    using Moveax.Pluralization.Common.Resources.DateTime;
    using Moveax.Pluralization.Core;

    /// <summary>Provide pluralized and localized values of date and time units.</summary>
    public class DateTimePluralizer
    {
        private readonly Pluralizer _pluralizer;

        /// <summary>Initializes a new instance of the <see cref="DateTimePluralizer"/> class.</summary>
        /// <param name="cultureInfo">An object that represents the culture for which the resource is localized.</param>
        public DateTimePluralizer(CultureInfo cultureInfo)
        {
            this._pluralizer = new Pluralizer(cultureInfo, new ResourceStringsSource(DateTimeResources.ResourceManager));
        }

        /// <summary>Gets the pluralized and localized value of specified date or time unit.</summary>
        /// <param name="amount">The amount.</param>
        /// <param name="units">The units.</param>
        /// <returns>The string value the represent localized and pluralized unit for the specified amount.</returns>
        public string GetStringFor(int amount, DateTimeUnit units)
        {
            return this._pluralizer.Pluralize(units.ToString(), amount);
        }

        /// <summary>Gets the pluralized and localized value of specified date or time unit.</summary>
        /// <param name="amount">The amount.</param>
        /// <param name="units">The units.</param>
        /// <returns>The string value the represent localized and pluralized unit for the specified amount.</returns>
        public string GetStringFor(float amount, DateTimeUnit units)
        {
            return this._pluralizer.Pluralize(units.ToString(), amount);
        }
    }
}
